import './style.less';
import { initConfig, initSdk, initApp, initStyle, resizeHtmlFontSize } from '@keenoho/site-builder';
import '@keenoho/keenoho-ui/dist/root.css';
import '@keenoho/keenoho-ui/dist/index.css';
import KeenohoUI from '@keenoho/keenoho-ui';
import App from './App.vue';

// init
initStyle();
resizeHtmlFontSize();
window.addEventListener('resize', resizeHtmlFontSize);

// start to run
async function start() {
  // prepare setting
  const config = initConfig();
  const sdk = await initSdk(config).catch((err) => {
    console.error(err);
  });

  const beforeAppMount = async (app) => {
    app.use(KeenohoUI);
    app.config.globalProperties.$config = config;
    app.config.globalProperties.$sdk = sdk;
  };

  // render app
  const app = await initApp('root', {}, App, beforeAppMount);
  window.__APP__ = app;
}
start();
